import java.io.File;

import gui.MainWindow;
import gui.view.android.AndroidDrawersRegistry;

import javax.swing.JFrame;

import com.nightpiter.controller.log.AbstractLogger;
import com.nightpiter.controller.log.Logger;

import model.readers.ReadersRegistry;
import model.readers.PMetro.Reader;
import model.savers.MetroSaversRegistry;
import model.savers.StandardSaver;


public class Main {
	public static void main(String args[]) {
		//ReadersRegistry.addFormat("AndroidMetro map(*.xml)","xml", new SaxReader());
		ReadersRegistry.addFormat("PMetro map(*.pmz)","pmz", new Reader());
		ReadersRegistry.getReaderFromJar("c:\\reader.jar");
		MetroSaversRegistry.addSaver("AndroidMetro map(*.xml)", "xml", new StandardSaver());
		Logger.initLogger(new AbstractLogger() {

			@Override
			public void log(String tag, String message) {
				System.out.println(tag + ":" + message);
				
			}
			
		});
		
		JFrame mainWindow = new MainWindow();
		loadDrawers();
		loadReaders();
		mainWindow.setVisible(true);		
	}
	
	private static void loadDrawers() {
		File file = new File("drawers");
		for(File f:file.listFiles()) {
			AndroidDrawersRegistry.getDrawerFromJar(f.getAbsolutePath());
		}
	}
	
	private static void loadReaders() {
		File file = new File("readers");
		for(File f:file.listFiles()) {
			ReadersRegistry.getReaderFromJar(f.getAbsolutePath());
		}
	}
	

}
